import static java.lang.Thread.sleep;

public class text17 {
    public static void main11(String[] args) {
        Thread thread=new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(1);
            }
        });
        thread.start();

            try {
                Thread.sleep(1000);
                System.out.println(thread.isAlive());
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

    }
    public static void main12(String[] args) {
        Thread thread=new Thread(new Runnable() {
            @Override
            public void run() {
               int i=0;
               for(i=0;i<8;i++)
               {
                   System.out.println(1);
               }
            }
        });
        thread.start();
        System.out.println(3);
        try {
            thread.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(2);
    }
    public static void main4(String[] args) {
        Thread thread=new Thread(new Runnable() {
            @Override
            public void run() {
                while(!Thread.currentThread().isInterrupted())
                {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println(1);
                }

            }
        });
        thread.start();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        thread.interrupt();
        //System.out.println(2);
    }
    public static void main3(String[] args) {
        boolean flag=true;
        Thread thread=new Thread(new Runnable() {

            @Override
            public void run() {
                while(true) {
                    System.out.println("hello");
                }

            }
        });
        thread.start();
        //flag=false;

    }
    public static void main(String[] args) {
        Thread thread=new Thread(new Runnable() {
            @Override
            public void run() {
                int i = 0;
                for (i = 0; i < 3; i++) {


                    System.out.println("hello");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }
            }



        });
        thread.start();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("world");
    }

    public static void main1(String[] args) {
        Thread thread=new Thread(new Runnable() {
            @Override
            public void run() {
                //System.out.println("hello");
                System.out.println("1");

            }
        });
        thread.start();
        //System.out.println("world");
        System.out.println("2");

    }
}
